﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using XQ.Framework.model;
using lib;
using XQ.Framework.core;

namespace XQ.Framework.html
{
    public class CommonHtml
    {
        public static string GetMenuHtml(List<LinkModelBase> list)
        {
            return CommonHtml.GetMenuHtml(list, "no flag");
        }
        public static string GetMenuHtml(List<LinkModelBase> list, string flag)
        {
            try
            {
                if (list == null || list.Count == 0) { return ""; }
                StringBuilder html = new StringBuilder();
                html.Append("<ul class='menu'>");
                for (int i = 0; i < list.Count; ++i)
                {
                    if (list[i] == null) { continue; }
                    html.Append(list[i].Flag == flag ? "<li class='selected'>" : "<li>");
                    html.Append(HtmlHelper.getLinkHtml(list[i]));
                    html.Append("</li>");
                }
                html.Append("</ul>");
                return html.ToString();
            }
            catch (Exception e)
            { return e.Message; }
        }
    }
}
